package com.it.tydic.estate.module.controller.xqgl;

import com.it.tydic.estate.common.annotation.ControllerDesc;
import com.it.tydic.estate.common.aop.Result;

import com.it.tydic.estate.common.constants.LogConstants;
import com.it.tydic.estate.module.model.inner.Louyu;
import com.it.tydic.estate.module.service.LouyuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 楼宇管理
 */
@RestController
@RequestMapping("louyu")
@Api(tags = "楼宇管理")
public class LouyuController {
    @Autowired
    private LouyuService louyuService;
    private static final Logger logger = LoggerFactory.getLogger(LouyuController.class);

    /**
     * 新增或修改
     *
     * @param louyu 楼宇对象
     * @return
     */
    @PostMapping("/addOrUpload")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @ApiOperation(value = "楼宇添加或修改")
    public Result addOrUpload(@RequestBody Louyu louyu) {

        return louyuService.addOrUpload(louyu);
    }

    /**
     * 楼宇条件查询
     *
     * @param louyuMap 查询条件
     * @return
     */
    @PostMapping("query")
    @ApiOperation(value = "条件查楼宇信息", notes = "条件查楼宇信息")
    public Result queryList(@RequestBody Map<String, Object> louyuMap) {
        return louyuService.queryList(louyuMap);
    }

    /**
     * 根据主键删除楼宇
     *
     * @param id 主键
     * @return
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "根据主键删除楼宇", notes = "根据主键删除楼宇")
    @ControllerDesc(description = LogConstants.delete_data)
    public Result deleteById(@PathVariable String id) {

        return louyuService.deleteById(id);
    }

    /**
     * 批量删除
     *
     * @param list 主键集合
     * @return
     */
    @PostMapping("/deleteBatch")
    @ApiOperation(value = "批量删除", notes = "批量删除")
    @ControllerDesc(description = LogConstants.delete_data)
    public Result deleteBatch(@RequestBody List<String> list) {
        return louyuService.deleteBatch(list);
    }
    /**
     * 根据主键查询楼宇
     *
     * @return
     */
    @GetMapping("queryById{id}")
    @ApiOperation(value = "根据主键查询楼宇", notes = "根据主键查询楼宇")
    public Result queryById(@PathVariable String id) {
        return louyuService.queryById(id);
    }
    /**
     * 根据小区主键查楼宇
     * @param id
     * @return
     */
    @GetMapping("queryByLyId/{id}")
    @ApiOperation(value = "根据小区主键查楼宇", notes = "根据小区主键查楼宇")
    public Result queryByLyId(@PathVariable String id) {
        return louyuService.queryByLyId(id);
    }
}
